package com.leecode.acs;

/**
 * @description: 一个数组中只有两种字符G和B想让所有的G都放在左侧，所有的B都放在右侧但是只能在相邻字符之间进行交换操作返回至少需要交换几次
 * [G,B,B,G,G,G,B,G,B,B]
 * [G,G,G,G,G,B,B,B,B,B]
 * @date: 2023/1/14 17:05
 * @author: yaoshubin
 * @version: 1.0
 */
public class ACS_03_贪心算法_G左B右 {

    public static void main(String[] args) {
        String[] arr = {"B", "B", "B", "G", "G", "G", "B", "G", "B", "B"};
        int minTime = minTimes(arr);
        System.out.println(minTime);
    }

    public static int minTimes(String[] arr) {
        if (arr == null || arr.length == 0) {
            return 0;
        }
        int L = 0;
        int R = 0;
        int len = arr.length;
        int minTimes = 0;
        for (int i = 0; i < len; i++) {
            if (arr[R] == "G") {
                R++;
            }
        }

        return minTimes;
    }
}
